package com.sparrow.manage.common.service.impl;

import com.sparrow.manage.common.dao.AttachmentDao;
import com.sparrow.manage.common.entity.Attachment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AttachmentService extends BaseServiceImpl<Attachment, String> {

    @Autowired
    private AttachmentDao attachmentDao;

    @Override
    protected JpaRepository<Attachment, String> getDao() {
        return attachmentDao;
    }

    @Override
    public Attachment insert(Attachment attachment) {
        attachment.setCreateTime(new Date());
        return attachmentDao.save(attachment);
    }

    public List<Attachment> queryByRelateId(String id) {
        return attachmentDao.queryByRelateId(id);
    }
}
